package cn.pzx.base_module.http

/**
 * @author pzx
 * @description:
 * @date :3/3/21 4:46 PM
 */
class BaseResult<T> {
    val data: T? = null
    val errorCode: Int = 0;
    val errorMsg: String? = "";
    var exception: Exception? = null;
}

inline fun <T> BaseResult<T>.next(bloc: BaseResult<T>.() -> Unit): BaseResult<T> {
    return if (exception == null) {//没有异常，则把正确结果bloc出去
        bloc()
        this
    } else {//出现异常（网络/服务器/自定义异常）执行这里 不用bloc
        this;
    }

}


inline fun <T> BaseResult<T>.catchException(bloc: Exception.() -> Unit) {
    if (exception != null) {
        bloc(exception!!)
    }
}